<?php
ob_start();  
session_start();
 
     $access_token_page = $_GET['access_token_page'];
    
    // echo$access_token_page;
     $servizio="Facebook";
     
     
     $ris = InsertTokenPage($_SESSION['id'],$access_token_page,$servizio);
     
     ?><script>
                        
                window.opener.location.reload(); 
                setTimeout('window.close()',100);
                        
       </script>
     <?php
   
     
 
     function InsertTokenPage($idutente,$access_token_page,$service){
   
                     
                        //retrive base url 
                        $url = $_SESSION['basic_url'];
                        //add service url
                        $service_url="/InsertTokenPage?";
                        //params url
                        $params = array('id'=>$_SESSION['id'],'access_token'=>$access_token_page,'service'=>$service);
                        //params connection
                        $ctx = stream_context_create(array('http' => array('timeout' => 1))); 
                        //send GET request
                        $output = @file_get_contents($url.$service_url."id=".$params['id']."&"."access_token=".$params['access_token']."&"."service=".$params['service'],0,$ctx);
                        //parse JSON output
                      //  print_r($url.$service_url."id=".$params['id']."&"."access_token=".$params['access_token']."&"."service=".$params['service']); break;
                        $data = json_decode($output);
                        $webResult = $data->InsertTokenPageResult;
                        
                        //print_r($webResult); break;
                        return$webResult;
                        

                     
 }                        
                        
                     
                        
  
  
     
?>



